#include "appsettings.hpp"

// Initialize static Variables
AppSettings* AppSettings::instance = NULL;
int AppSettings::instanceCounter = 0;


AppSettings::AppSettings() :
    QObject()
{
    settings = new QSettings(QDir::currentPath().append("settings.ini") ,QSettings::IniFormat, this);
}


AppSettings::~AppSettings()
{
    delete settings;
}

AppSettings *AppSettings::getInstance()
{
    if (++instanceCounter == 1)
        instance = new AppSettings();

    return instance;
}


void AppSettings::releaseInstance()
{
    if (--instanceCounter == 0)
        delete instance;
}


void AppSettings::setMainWindowGeometry(QByteArray value)
{
    settings->setValue("general/mainWindowGeometry", value);
}


QByteArray AppSettings::getMainWindowGeometry()
{
    return settings->value("general/mainWindowGeometry").toByteArray();
}


void AppSettings::setMainWindowState(QByteArray value)
{
    settings->setValue("general/mainWindowState", value);
}


QByteArray AppSettings::getMainWindowState()
{
    return settings->value("general/mainWindowState").toByteArray();
}


bool AppSettings::contains(QString key) const
{
    return this->settings->contains(key);
}
